<!DOCTYPE html>
<html class="" lang="en">
	<head>
		{% include 'twig/common/header/include.twig' %}
		<script src="/dev/lib/handlebars-v4.0.10.js" type="text/javascript" charset="utf-8"></script>
		<script src="/dev/lib/bootstrap-paginator/src/bootstrap-paginator.js?v={{_version}}" type="text/javascript"></script>
		<script src="/dev/js/admin/project.js?v={{_version}}" type="text/javascript" charset="utf-8"></script>
	</head>
	<body class="" data-group="" data-page="projects:issues:index" data-project="xphp">
		{% include 'twig/common/body/script.twig' %}

		<section class="has-sidebar page-layout max-sidebar">
			{% include 'twig/common/body/page-left.twig' %}

			<div class="page-layout page-content-body system-page">
				{% include 'twig/common/body/header-content.twig' %}

				<script>
					var findFileURL = "";
				</script>
				<div class="page-with-sidebar">

					{% include 'twig/admin/common-page-nav-admin.twig' %}

					<div class="content-wrapper page-with-layout-nav page-with-sub-nav">
						<div class="alert-wrapper">

							<div class="flash-container flash-container-page"></div>

						</div>
						<div class="container-fluid">
							<div class="content" id="content-body">
								{% include 'twig/admin/common_project_left_nav.twig' %}
								<div class="row has-side-margin-left">
									<div class="col-lg-12">
										<div class="top-area">
											<ul class="nav-links user-state-filters" style="float:left">
												<li class="active" data-value="">
													<a id="state-opened" title="项目列表">
													<span>
														项目列表
													</span>
													</a>
												</li>
											</ul>
											<div class="nav-controls" style="">
												<!--a class="btn has-tooltip" title="" href="#" data-original-title="邀请用户">
                                                                            <i class="fa fa-rss"></i>
                                                                        </a-->
												<div class="project-item-select-holder">
													<a class="btn btn-new new-project-item-select-button js-key-create" data-key-mode="new-page" href="/project/main/new">
														<i class="fa fa-plus"></i>
														新建项目
													</a>
												</div>
											</div>
										</div>

										<div class="content-list pipelines">
											<div class="table-holder">
												<table class="table">
													<thead>
													<tr>
														<th class="js-pipeline-info pipeline-info">名称</th>
														<th class="js-pipeline-info pipeline-info">KEY</th>
														<th class="js-pipeline-info pipeline-info">项目类型</th>
														<th class="js-pipeline-stages pipeline-info">项目负责人</th>
														<th class="pipeline-info">操作</th>
													</tr>
													</thead>
													<tbody id="render_id"></tbody>
												</table>
											</div>
											<div class="gl-pagination" id="ampagination-bootstrap"></div>
										</div>
									</div>


								</div>
							</div>
						</div>

					</div>
				</div>

			</div>
		</section>

		{% verbatim %}
			<script type="text/html" id="project_tpl">
				{{#rows}}
					<tr class="commit">
						<td>
							<a href="/{{path}}/{{key}}" class="commit-id monospace" target="_blank">
								{{name}}
							</a>
						</td>
						<td>
							<a href="/{{path}}/{{key}}" class="commit-id monospace" target="_blank">
								{{key}}
							</a>
						</td>
						<td>
							<a href="javascript:void(0);" class="commit-id monospace">
								{{type_name}}
							</a>
						</td>
						<td>
							<a href="javascript:void(0)" class="commit-id monospace">
								{{leader_display}}
							</a>
						</td>
						<td>
							<a class="user_for_edit btn btn-transparent " style="padding: 6px 2px;" onclick="adminDoArchived({{id}}, '{{name}}')">归档
							</a>

							<a class="user_for_edit btn btn-transparent " href="/{{path}}/{{key}}/settings" data-uid="{{uid}}" style="padding: 6px 2px;" target="_blank">编辑
							</a>

							<a class="user_for_delete btn btn-transparent" style="padding: 6px 2px;" onclick="admindDoDelete({{id}}, {{type}}, '{{name}}')">
								<i class="fa fa-trash"></i>
								<span class="sr-only">Remove</span>
							</a>

						</td>
					</tr>
				{{/rows}}

			</script>
		{% endverbatim %}

		<script>

			$(function () {
                fetchList('/admin/project/filterData', 'project_tpl', 'render_id', 1, 0);
            });
            function adminDoArchived(projectId, projectName) {
                var message = "确认是否归档项目: " + projectName;

                if (window.confirm(message + "？")) {
                    projectArchived(projectId);
                    fetchList('/admin/project/filterData', 'project_tpl', 'render_id', 1, 0);
                } else { // 取消
                }
            }
			function randomNumber(min, max) {
				return parseInt(Math.random() * (max - min) + min);
			}
            function admindDoDelete(projectId, projectTypeId, projectName) {
                let message = "确认是否删除项目: " + projectName+"? 删除操作将不可逆转，请谨慎操作!";
                if (window.confirm(message)) {
                	let a = randomNumber(10, 20);
					let b = randomNumber(2, 20);
                	let question = a + " + " + b +" = ?"
                	let ret = window.prompt(question);
                	if(parseInt(ret)===(a+b)){
						projectRemove(projectId, projectTypeId);
						fetchList('/admin/project/filterData', 'project_tpl', 'render_id', 1, false);
					}else{
                		alert('回答错误');
					}
                }
            }
		</script>

		<div class="modal fade" tabindex="-1" role="dialog" id="myModal">
			<div class="modal-dialog modal-sm" role="document">
				<div class="modal-content modal-middle">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close">
							<span aria-hidden="true">&times;</span>
						</button>
						<h4 class="modal-title">提示</h4>
					</div>
					<div class="modal-body">
						<p>是否确认删除？</p>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-primary">确定</button>
						<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					</div>
				</div>
			</div>
		</div>
	</body>
</html>
